<?php
class tags_events_composition extends composite_table {
	/**
	 * tags table
	 *
	 * @var tags
	 */
	public $tags;
	/**
	 * tags_events table
	 *
	 * @var tags_events
	 */
	public $tags_events;

	/**
	 * Constructor
	 *
	 * @param mixed $id
	 */
	public function __construct($id = null) {
		parent::__construct($id);
	}

	/**
	 * Gets slave table relations as array of query_criteria objects where key is relation table
	 *
	 * @return array
	 */
	protected function get_tables_relations() {
		$out = array();
		
		$criteria = new query_criteria();
		
		$criteria->add_custom_criterion(sprintf("%s.%s = %s.%s",
			$this->tags->get_table_name(), $this->tags->tag_id->get_field_name(),
			$this->tags_events->get_table_name(), $this->tags_events->tag_id->get_field_name()));
		$out[] = new relations_wrapper($this->tags_events->get_table_name(), join_type::$inner, $criteria);
		
		return $out;
	}
}
?>